/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.games.epkb.entityClasses;

import java.io.Serializable;
import java.math.BigInteger;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author plebani
 */
@Entity
@Table(name = "activity_data")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ActivityData.findAll", query = "SELECT a FROM ActivityData a"),
    @NamedQuery(name = "ActivityData.findByIdActivity", query = "SELECT a FROM ActivityData a WHERE a.activityDataPK.idActivity = :idActivity"),
    @NamedQuery(name = "ActivityData.findByIdDataFile", query = "SELECT a FROM ActivityData a WHERE a.activityDataPK.idDataFile = :idDataFile"),
    @NamedQuery(name = "ActivityData.findByQuantity", query = "SELECT a FROM ActivityData a WHERE a.quantity = :quantity"),
    @NamedQuery(name = "ActivityData.findByDimension", query = "SELECT a FROM ActivityData a WHERE a.dimension = :dimension")})
public class ActivityData implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ActivityDataPK activityDataPK;
    @Column(name = "Quantity")
    private Integer quantity;
    @Column(name = "Dimension")
    private BigInteger dimension;
    @JoinColumn(name = "Id_DataFile", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private DataFile dataFile;
    @JoinColumn(name = "Id_Activity", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Activity activity;

    public ActivityData() {
    }

    public ActivityData(ActivityDataPK activityDataPK) {
        this.activityDataPK = activityDataPK;
    }

    public ActivityData(String idActivity, String idDataFile) {
        this.activityDataPK = new ActivityDataPK(idActivity, idDataFile);
    }

    public ActivityDataPK getActivityDataPK() {
        return activityDataPK;
    }

    public void setActivityDataPK(ActivityDataPK activityDataPK) {
        this.activityDataPK = activityDataPK;
    }

    public Integer getQuantity() {
        return quantity;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    public BigInteger getDimension() {
        return dimension;
    }

    public void setDimension(BigInteger dimension) {
        this.dimension = dimension;
    }

    public DataFile getDataFile() {
        return dataFile;
    }

    public void setDataFile(DataFile dataFile) {
        this.dataFile = dataFile;
    }

    public Activity getActivity() {
        return activity;
    }

    public void setActivity(Activity activity) {
        this.activity = activity;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (activityDataPK != null ? activityDataPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ActivityData)) {
            return false;
        }
        ActivityData other = (ActivityData) object;
        if ((this.activityDataPK == null && other.activityDataPK != null) || (this.activityDataPK != null && !this.activityDataPK.equals(other.activityDataPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.polimi.games.epkb.entityClasses.ActivityData[ activityDataPK=" + activityDataPK + " ]";
    }
    
}
